package com.osfw.activiti.enums;


import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 流程用户类型
 */
public enum ProcUserType {

    STARTER("starter", "发起人"),
    PARTICIPANT("participant", "参与人"),
    ASSIGNEE("assignee", "签收人"),
    CANDIDATE("candidate", "候选人"),
    OWNER("owner", "所有者"),
    Leader("leader", "领导者");

    private String code;
    private String name;

    ProcUserType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }


    public static ProcUserType getProcUserType(String code) {
        for (ProcUserType typeEnum : values()) {
            if (typeEnum.getCode().equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static Map<String, String> getProcUserTypeList() {
        HashMap<String, String> map = new LinkedHashMap<>();
        for (ProcUserType typeEnum : values()) {
            map.put(typeEnum.getCode(), typeEnum.getName());
        }
        return map;
    }

}
